# other.jl
# Some statistics for the referees

using LinearAlgebra
using Gadfly
using DataFrames

# Upstreamness:
Δ = reshape(cenf.lhs[106,:,:],35,35)
upstreamness = (I - Δ)\ones(Float64, 35)


plot(x=upstreamness, Geom.histogram)

upstreamness_ij = (((I - Δ)*(I - Δ))\Δ) ./ ((I - Δ)\Δ)

repeat(collect(1:35)', 35,1)

IS = zeros(Float64, 35,35)
for n = 1:35
    for i = 1:35
        global IS
        IS[n,i] = Δ[n,:]'*Δ[i,:]
    end
end

df = DataFrame(downstream = vec(repeat(collect(1:35), 35,1)), upstream = vec(repeat(collect(1:35)', 35,1)), upstreamness = vec(upstreamness_ij), is = vec(IS))
using FileIO

using CSV
CSV.write("upstreamness_ij.csv", df)